import java.util.Arrays;
import java.util.Random;

public class Test {

    public static void readyDataOrder(int[] array){
        for (int i = 0; i < array.length; i++) {
//            array[i] = i;
            array[i] = array.length - 1;
        }
    }

    public static void readyDataNotOrder(int[] array){
        Random random = new Random();

        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(100000);
        }
    }

    public static void testInsertSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.insertSort(array);
        long end = System.currentTimeMillis();
        System.out.println("插入排序耗时(参考)：" + (end - start));
    }

    public static void testShellSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.shellSort(array);
        long end = System.currentTimeMillis();
        System.out.println("希尔排序耗时(参考)：" + (end - start));
    }

    public static void testSelectSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.selectSort(array);
        long end = System.currentTimeMillis();
        System.out.println("选择排序耗时(参考)：" + (end - start));
    }

    public static void testHeapSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.heapSort(array);
        long end = System.currentTimeMillis();
        System.out.println("堆排序耗时(参考)：" + (end - start));
    }

    public static void main(String[] args) {
        int[] array = new int[10_0000];
        readyDataOrder(array);
        testInsertSort(array);
        testShellSort(array);
        testSelectSort(array);
        testHeapSort(array);
    }

    public static void main1(String[] args) {
        int[] array = {10,1,2,3,7,9,6,5,4,8};
//        Sort.insertSort(array);
//        System.out.println(Arrays.toString(array));
//        System.out.println("==========================");
//
//        Sort.shellSort(array);
//        System.out.println(Arrays.toString(array));
//        System.out.println("==========================");
//
//        Sort.selectSort(array);
//        System.out.println(Arrays.toString(array));
//        System.out.println("==========================");
//
//        Sort.selectSort2(array);
//        System.out.println(Arrays.toString(array));
//        System.out.println("==========================");

        Sort.heapSort(array);
        System.out.println(Arrays.toString(array));
        System.out.println("==========================");
    }
}
